﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CosmosKernel4.UI.Shell
{
    class PLSMSH
    {
        List<Command> _cmdlist = new List<Command>();

        public void do_plsmsh()
        {
            _cmdlist.Add(new Commands.Hello());


            Console.WriteLine("Welcome to Plasmid, " + GruntyOS.CurrentUser.Username + ". Enter 'help' to get just that");
            /*Byte[] data = { 0x66, 0xB8, 0x00, 0x80, 0x0B, 0x00, 0x67, 0xC6, 0x00, 0x41, 0xC3 };
            CosmosKernel4.Global.Bex.execute(data);*/
            for (; ; )
            {
                Console.Write(GruntyOS.CurrentUser.Username + "@" + CosmosKernel4.Global.Config.compname + ">");
                string inp = Console.ReadLine();
                string[] cmds = inp.Split(' ');

                string firstCommand = cmds[0];
               

                for (int i = 0; i < _cmdlist.Count; i++)
                {
                    if (_cmdlist[i].Name == firstCommand)
                    {
                        _cmdlist[i].Execute(cmds);
                    }
                    else
                    {
                        if (firstCommand == "logout")
                        {
                            Console.Clear();
                            return;


                        }
                        else
                        {
                            if (firstCommand == "help")
                            {
                                for (int n = 0; n < _cmdlist.Count; n++)
                                {
                                    Console.WriteLine(_cmdlist[i].Name + ":" + _cmdlist[i].Help);
                                }
                                Console.WriteLine("logout:Exactly what it says on the tin");
                                Console.WriteLine("help:You know what this does, you just saw it");
                            }
                            else
                            {
                                Console.WriteLine("Command not found");
                            }
                        }
                    }
                }
            }
        }
    }
}
